<template>
  <div id="cornerComment" v-if="dialogVisible">
    <div class="cornerComment-in">
      <div class="cornerComment-in-title">
        <span>{{ cornerOption.corner.name }}-{{ cornerOption.class.class_name }}-预约详情</span>
        <span class="el-icon-circle-close close-Btn-line" @click="closePOpup"></span>
      </div>
      <div class="commentBody">
        <!--        <div class="mb-10">-->
        <!--          <div class="toplineBox">-->
        <!--            <div class="toplineBox-left">-->
        <!--              &lt;!&ndash;<el-input v-model="searchWord.corner_name" placeholder="填写区角名称" size="small" class="w-140"></el-input>&ndash;&gt;-->
        <!--              <el-input v-model="searchWord.name" placeholder="填写学生姓名" size="small" class="w-140"></el-input>-->
        <!--              <el-button type="primary" @click="searchBtn" size="small"><i class="el-icon-search"></i>搜索</el-button>-->
        <!--              <el-button size="small" @click="refreshFn"><i class="el-icon-refresh"></i>重置刷新</el-button>-->
        <!--            </div>-->
        <!--            <p class="numberline toplineBox-right">总{{ page.total }}条</p>-->
        <!--          </div>-->
        <!--        </div>-->
        <div class="table-body">
          <div class="table-body-box">
            <el-table
                ref="multipleTable"
                :data="arryList"
                :stripe="tableoption.tableStripe"
                :border="tableoption.tableBorder"
                tooltip-effect="dark"
                style="width: 100%"
                header-cell-class-name="table-text-c"
                cell-class-name="table-text-c">
              <el-table-column
                  label="学生头像" align="center">
                <template slot-scope="scope">
                  <viewerModle type="1" :imgSrc="scope.row.student.pic"></viewerModle>
                </template>
              </el-table-column>
              <el-table-column
                  label="学生姓名" align="center">
                <template slot-scope="scope">
                  {{ scope.row.student ? scope.row.student.name : '未知' }}
                </template>
              </el-table-column>
              <el-table-column
                  label="班级" align="center">
                <template slot-scope="scope">
                  {{ cornerOption.class.class_name }}
                </template>
              </el-table-column>
              <el-table-column
                  label="操作"
                  width="200" align="center">
                <template slot-scope="scope">
                  <el-button size="small" @click="addActive(scope.row)">查看学生实时采集（{{ scope.row.comment_number }}）
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
        <!--工具条 分页-->
        <el-col :span="24" class="toolbarLine">
          <el-pagination
              background
              :page-size="page.pagesize"
              :current-page="page.pageindex"
              layout="total, prev, pager, next"
              :total="page.total"
              @current-change="handleSizeChange"></el-pagination>
        </el-col>
      </div>
      <div class="cornerComment-in-footer">
        <el-button type="primary" @click="closePOpup" size="small">确定</el-button>
      </div>
    </div>
    <studentCorner :visible.sync="dayCollectVisible" :collectOption="collectOption"></studentCorner>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js';
import studentCorner from "./studentCorner";

export default {
  props: ['visible', 'cornerOption'], // commoent 学生点评 collection 学生采集
  components: {
    studentCorner
  },
  data() {
    return {
      dayCollectVisible: false,
      dialogVisible: false,
      tableoption: tableoption,
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      arryList: [],
      collectOption: {}
    }
  },
  watch: {
    visible() {
      this.dialogVisible = this.visible
      if (this.visible) {
        this.InitFn()
      } else {
        this.arryList = []
      }
    }
  },
  created() {
  },
  methods: {
    // 初始化
    async InitFn() {
      console.log('页面请求的数据内容：', this.cornerOption)
      let option = {
        p: this.page.pageindex,
        class_id: this.cornerOption.class.id,
        corner_id: this.cornerOption.corner.id
      }
      let data = await this.$post(this.api.admin_corner_apply_list, option);
      console.log('data:', data)
      this.arryList = data.list.data
      this.page.total = data.list.total
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    // 关闭弹窗
    closePOpup() {
      this.$emit('update:visible', false)
    },
    showCollectBox(option) {
      this.collectOption = {
        student_id: this.studentId.id,
        corner_id: option.corner_id,
        corner_name: option.corner.name,
        student_name: this.studentId.name
      };
      this.dayCollectVisible = true;
    },
    addActive(option) {
      this.collectOption = {
        student_id: option.student_id,
        corner_id: this.cornerOption.corner.id,
        student_name: option.student.name,
        class_name: this.cornerOption.class.class_name,
        corner_name: this.cornerOption.corner.name
      }
      this.dayCollectVisible = true
    }
  },
  mounted() {
  }
}
</script>
<style scoped>
#cornerComment {
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9;
}

.cornerComment-in {
  width: 70%;
  height: 65%;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-radius: 5px;
}

.cornerComment-in-title {
  height: 50px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ddd;
  font-size: 24px;
}

.cornerComment-in-title span {
  padding: 0 10px;
}

.cornerComment-in-title span:first-child {
  flex: 1;
  font-size: 16px;
}

.cornerComment-in-footer {
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  padding: 0 10px;
  justify-content: center;
}

.commentBody {
  padding: 20px 10px;
  flex: 1;
  overflow-y: auto;
}

.close-Btn-line {
  cursor: pointer;
}

.toolbarLine {
  text-align: center;
}
</style>


